Skip to content

Conversation

@tejlmand
Copy link
Contributor

Declaration of variables after a label inside a switch statement is a c23 extension, not c99.

This results in the following warning when compiling with clang:

.../subsys/net/lib/zperf/zperf_shell.c:912:4: warning: label followed
by a declaration is a C23 extension [-Wc23-extensions]
912 | int seconds = parse_arg(&i, argc, argv);
| ^
.../subsys/net/lib/zperf/zperf_shell.c:1145:4: warning: label followed
by a declaration is a C23 extension [-Wc23-extensions]
1145 | int seconds = parse_arg(&i, argc, argv);
| ^
2 warnings generated.

There are no practical reasons why the variable should be declared inside the switch statement, therefore move the declaration and place it together with declaration of other variables.

Upstream PR #: 88403

Declaration of variables after a label inside a switch statement is a
c23 extension, not c99.

This results in the following warning when compiling with clang:
> .../subsys/net/lib/zperf/zperf_shell.c:912:4: warning: label followed
>                by a declaration is a C23 extension [-Wc23-extensions]
>   912 |                      int seconds = parse_arg(&i, argc, argv);
>       |                         ^
> .../subsys/net/lib/zperf/zperf_shell.c:1145:4: warning: label followed
>                by a declaration is a C23 extension [-Wc23-extensions]
>  1145 |                      int seconds = parse_arg(&i, argc, argv);
>       |                         ^
> 2 warnings generated.

There are no practical reasons why the variable should be declared
inside the switch statement, therefore move the declaration and place it
together with declaration of other variables.

Upstream PR #: 88403

Signed-off-by: Torsten Rasmussen <[email protected]>
@tejlmand tejlmand force-pushed the zperf_seconds_declaration_fix branch from 540b5a0 to a09f3d5 Compare April 10, 2025 07:40
@sonarqubecloud
Copy link

@tejlmand tejlmand merged commit 25e27e3 into nrfconnect:main Apr 10, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport v4.0.99-ncs1-branch Relates to NCS v3.0-branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants